# -*- coding: utf-8 -*-
# @Time: 2025/9/27 1:59
# @Author: foxhuty
# @File: users.py
from models import Base
from sqlalchemy.orm import relationship
from sqlalchemy import Column, Integer, String, ForeignKey


class User(Base):
    __tablename__ = 'user'
    id = Column(Integer, primary_key=True, autoincrement=True, index=True)
    email = Column(String(100), unique=True, index=True)
    username = Column(String(100), unique=True)
    password = Column(String(200), nullable=False)


class UserExtension(Base):
    __tablename__ = 'user_extension'
    id = Column(Integer, primary_key=True, index=True)
    university = Column(String(100))

    user_id = Column(Integer, ForeignKey("user.id"))
    # 使用uselist=False，表示和User建立一对一的关系
    user = relationship(User, backref='extension', uselist=False)

